<template>
	<view class="content ">
		<hx-navbar ref="hxnb" :config="config">
			<block slot="max">
				<view class="nav_wrap flex">
					<view class="back_wrap flex">
						<view class="diqu">律师端</view>
					</view>
					<view class="page_title font_16_FFF">
						<image src="../../../../static/img/home/logo.png" mode="aspectFill"></image>
					</view>
				</view>
			</block>
		</hx-navbar>


		<view class="main-div">
			<image v-show="current%3==1" class="main-bg" src="../../../../static/img/home/home-bg.png" mode=""></image>
			<image v-show="current%3==2" class="main-bg" src="../../../../static/img/home/home-bg1.png" mode=""></image>
			<image v-show="current%3==0" class="main-bg" src="../../../../static/img/home/home-bg2.png" mode=""></image>
			<!-- <image class="main-bg" src="../../../../static/img/home/home-bg.png" mode=""></image> -->
			<view class="zhanwei" :style="{'height':statusBarHeight+'rpx'}"></view>
			<view class="m-d">
				<view class="u-m-t-16 swiperdiv" >
					<u-swiper height="176" :list="lblist" bg-color="rgba(0,0,0,0)"  @change="changeswiper"></u-swiper>
				</view>
				<view class="gn-div">
					<view class="gn-item1 flex flex_sb">
						<view class="item1-item text_center" @click="topItem(0)">
							<image class="item1-icon" src="../../../static/img/lawyerVersion/h1-1.png" mode="aspectFill">
							</image>
							<view class="item-title">案源大厅</view>
							<view class="item-jj">新增{{indexList.num3?indexList.num3:0}}条</view>
						</view>
						<view class="item1-item text_center" @click="topItem(1)">
							<image class="item1-icon" src="../../../static/img/lawyerVersion/h2-1.png" mode="aspectFill">
							</image>
							<view class="item-title">精选案源</view>
							<view class="item-jj">新增{{indexList.num2?indexList.num2:0}}条</view>
						</view>
						<view class="item1-item text_center" @click="topItem(3)">
							<image class="item1-icon" src="../../../static/img/lawyerVersion/h3.png" mode="aspectFill">
							</image>
							<view class="item-title">律师协作广场</view>
							<view class="item-jj">新增{{indexList.num_app?indexList.num_app:0}}条</view>
						</view>
					</view>
				</view>
				<view class="laba-div flex flex_sb">
					<view class="flex">
						<image class="laba-icon" src="../../../../static/img/home/h-15.png" mode="aspectFill"></image>
						<view class="laba-text line_1" v-if="gnlist.length>0">
							恭喜{{gnlist[0].l_user.name}}{{gnlist[0].l_user.type==1?'律师':'法学生'}}在北京成案{{gnlist[0].price}}元
						</view>
					</view>
					<view class="laba-btn" @click="xibao">
						全部喜报
						<u-icon name="arrow-right" color="#666" size="24"></u-icon>
					</view>
				</view>
				<view class="ai-div">
					<image @click="addMess" class="ai-bg" src="../../../../static/img/home/ai-bg.png" mode="aspectFill"></image>
				</view>
				<view class="u-padding-32" v-if="lsdetail.level_id!=0">
					<view class="flex flex_sb ">
						<view class="">
							<span class="font_16_333 font_weight">精选推荐</span>
							<span class="font_12_999 u-m-l-14">海量真实案源助您快速成案</span>
						</view>
						<view class="font_12_666" @click="topItem(0)">
							全部案源
							<u-icon name="arrow-right" color="#666" size="24"></u-icon>
						</view>
					</view>
					<view class="flex flex_sb u-m-t-28">
						<view class="flex">
							<view class="jinri-text">今日</view>
							<view class="font_12_999 u-m-l-14">
								有 <span class="colred">{{online_num}}</span> 位律师正在参与抢案
							</view>
						</view>
						<view class="flex"  @click="bensheng">
							<view class="chbox  flex_cen flex" v-if="chboxSel">
								<u-icon name="checkbox-mark" color="#fff" size="20"></u-icon>
							</view>
							<view class="chbox-no" v-if="!chboxSel"></view>
							<view class="font_12_666 u-m-l-8">
								只看本省
							</view>
						</view>
					</view>
				</view>
				<view class="anli-div"  v-if="lsdetail.level_id!=0">
					<view class="anyuan u-m-b-20"  v-for="(item,index) in dataList" :key="index" @click="todetail(item)">
						<view class="flex flex_sb">
							<view class="font_weight" >
								<span v-if="item.serve">{{item.serve.name}}</span>
							</view>
							<view class="font_12_999">
								已跟进律师（{{item.has_follow_num}}/3）
							</view>
						</view>
						<view class="line_2 u-m-t-24">
							{{item.content}}
						</view>
						<view class=" flex flex_wrap u-p-b-24">
							<view class="bq-item u-m-t-20 u-m-r-20">
								<span v-if="!item.price_dur_min && !item.price_dur_max">面议</span>
								<span v-if="item.price_dur_min && !item.price_dur_max">{{item.price_dur_min}}以上</span>
								<span v-if="!item.price_dur_min && item.price_dur_max">{{item.price_dur_max}}以下</span>
								<span v-if="item.price_dur_min && item.price_dur_max">{{item.price_dur_min}}~{{item.price_dur_max}}</span>
							</view>
						</view>
						<view class="flex flex_sb u-p-t-24 ay-bo" >
							<view class="font_12_666 flex">
								<view class="" v-if="item.time_trans">{{item.time_trans}}</view>
								<view class="dizhi" v-if="item.province_name">{{item.province_name}}</view>
							</view>
							<view class="flex">
								<view class="btn1">
									独享
								</view>
								<view class="btn2">
									抢单
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<serverTime></serverTime>
		<gongzhonghaotanchuangVue></gongzhonghaotanchuangVue>
		<u-tabbar active-color="#FA3B21" :list="tabbar"></u-tabbar>
	</view>
</template>

<script>
	var statusBarHeight = (uni.getSystemInfoSync().statusBarHeight * 2);
	import gongzhonghaotanchuangVue from '../../../../components/gongzhonghaotanchuang/gongzhonghaotanchuang.vue';
	import serverTime from '../../../components/serverTime/serverTime.vue';
	export default {
		components: {
			gongzhonghaotanchuangVue,serverTime
		},
		data() {
			return {
				current:1,
				statusBarHeight: statusBarHeight,
				config: {
					maxSlot: true,
					back: false,
					barPlaceholder: false,
					backgroundColor: [0, '#CF000D'],
					slideBackgroundColor: [1, '#CF000D']
				},
				tabbar: '',

				lblist: [],
				chboxSel: false,
				
				online_num:'',
				dataList:[],
				gnlist:[],
				lsdetail:[],
				this_province:'',
				
				indexList:[]
			}
		},
		onPageScroll(e) {
			// 重点，用到滑动切换必须加上
			this.$refs.hxnb.pageScroll(e);
		},
		onLoad() {
			this.tabbar = [{
				iconPath: "/static/img/tabBar/1-2.png",
				selectedIconPath: "/static/img/tabBar/1-1.png",
				text: '首页',
				pagePath: "/subPackageA/pages/lawyerVersion/index/index"
			}, {
				iconPath: "/static/img/tabBar/2-2-2.png",
				selectedIconPath: "/static/img/tabBar/2-2-1.png",
				text: '工作台',
				// count: 2,
				isDot: true,
				pagePath: "/subPackageA/pages/lawyerVersion/staging/staging"
			}, {
				iconPath: "/static/img/tabBar/4-1.png",
				selectedIconPath: "/static/img/tabBar/4-2.png",
				text: '消息',
				// count: 2,
				isDot: false,
				pagePath: "/subPackageA/pages/lawyerVersion/message/message"
			}, {
				iconPath: "/static/img/tabBar/5-2.png",
				selectedIconPath: "/static/img/tabBar/5-1.png",
				text: '我的',
				pagePath: "/subPackageA/pages/lawyerVersion/mine/mine"
			}]
			
			
			uni.setStorage({
				key: 'userType',
				data: 2
			});
			
			
		},
		onShow() {
			this.getInfo()
			this.gegnlist()
			this.lunbo()
			this.lawyerindex()
		},

		methods: {
			toyonghu(){
				uni.reLaunch({
					url:"/pages/index/index"
				})
			},
			addMess(){
				if(this.lsdetail.is_ai==1){
					uni.navigateTo({
						url:"/subPackageA/pages/AI/AIcaht"
					})
				}else{
					uni.showToast({
						title: "无权限，请开通AI权限",
						icon: "none"
					});
				}
				
			},
			changeswiper(e){
				this.current = e+1
			},
			lawyerindex(){
				this.$api({
					url: '/lawyer/index',
					method: 'get',
				}).then(res => {
					if (res.code == 1) {
						this.indexList = res.data
					}
				})
			},
			//个人信息
			getInfo() {
				this.$api({
					url: '/lawyer/getLawyer',
					method: 'get',
					data: {
						token:uni.getStorageSync("token")
					},
				}).then(res => {
					if (res.code == 1) {
						this.lsdetail = res.data
						
						if(this.lsdetail.level_id!=0){
							this.getList()
						}
					} 
				})
				
			},
			lunbo(){
				this.$api({
					url: '/getBanner',
					method: 'get',
					data: {
						position: 9,
					},
				}).then(res => {
					if (res.code == 1) {
						this.lblist = res.data
					}
				})
			},
			bensheng(){
				this.chboxSel=!this.chboxSel
				if(this.chboxSel){
					this.this_province = 1
				}else{
					this.this_province = 0
				}
				this.getList()
			},
			gegnlist(){
				this.$api({
					url: '/lawyer/success_order',
					method: 'get',
					data: {
						token:uni.getStorageSync("token"),
						limit:100 
					},
				}).then(res => {
					if (res.code == 1) {
						this.gnlist = res.data.data
					} 
				})
			},
			getList(){
				this.$api({
					url: '/lawyer/case_square',
					method: 'get',
					data: {
						is_pay:1,
						token:uni.getStorageSync("token"),
						// cate_id:0,
						this_province:this.this_province,
						orderby:'created_at desc'
					},
				}).then(res => {
					if (res.code == 1) {
						this.dataList = res.data.list.data
						this.online_num = res.data.online_num
					} 
				})
			},
			xibao(){
				uni.navigateTo({
					url:"/subPackageA/pages/lawyerVersion/index/goodNews"
				})
			},
			todetail(e){
				uni.navigateTo({
					url:"/subPackageA/pages/lawyerVersion/index/anyuanDetail?id="+e.id
				})
			},
			topItem(e){
				
				if(e==3){
					uni.navigateTo({
						url:"/subPackageA/pages/lawyerVersion/index/xiezuoCenter"
					})
				}else{
					if(this.lsdetail.level_id!=0){
						uni.navigateTo({
							url:"/subPackageA/pages/lawyerVersion/index/anyuanCenter?type="+e
						})
					}else{
						uni.showToast({
							title: "无权限，请升级会员",
							icon: "none"
						});
					}
					
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.swiperdiv{
		width: 686rpx;
		height: 176rpx;
		margin: 0 auto;
	}
	.colred {
		color: #F92828;
	}
	.anli-div{
		width: 686rpx;
		border: 1rpx solid #F8ECEC;
		margin: 16rpx auto;
		// margin-top: 28rpx;
	}
	.anyuan{
		padding: 24rpx;
		background: #FFFFFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		.bq-item{
			background: #F7F7F7;
			border-radius: 6rpx 6rpx 6rpx 6rpx;
			border: 2rpx solid #D1D1D1;
			padding: 4rpx 14rpx;
		}
		.ay-bo{
			border-top: 1px #eee solid;
			.dizhi{
				border-left: 1px #eee solid;
				margin-left: 12rpx;
				padding-left: 12rpx;
			}
			.btn1{
				width: 120rpx;
				height: 56rpx;
				background: linear-gradient( 180deg, #FA2D2D 0%, #F40000 100%);
				border-radius: 32rpx 32rpx 32rpx 32rpx;
				font-size: 24rpx;
				color: #FFFFFF;
				font-weight: bold;
				text-align: center;
				line-height: 56rpx;
			}
			.btn2{
				width: 120rpx;
				height: 56rpx;
				background: #FFEBEB;
				border-radius: 32rpx 32rpx 32rpx 32rpx;
				border: 2rpx solid #FF9D9D;
				font-size: 24rpx;
				color: #F81B19;
				font-weight: bold;
				text-align: center;
				line-height: 56rpx;
				margin-left: 12rpx;
			}
		}
		
	}
	.jinri-text {
		background: linear-gradient(180deg, #FA2D2D 0%, #F40000 100%);
		border-radius: 6rpx 6rpx 6rpx 6rpx;
		font-size: 20rpx;
		color: #FFFFFF;
		padding: 2rpx 4rpx;
	}

	.chbox {
		width: 34rpx;
		height: 34rpx;
		background: #F81B1B;
		border-radius: 50%;
		text-align: center;
		// line-height: 24rpx;
	}

	.chbox-no {
		width: 34rpx;
		height: 34rpx;
		border-radius: 50%;
		border: 1px #999 solid;
	}

	.nav_wrap {
		width: 100%;
		position: relative;

		.back_wrap {
			position: absolute;
			left: 24rpx;

			.diqu {
				font-weight: 600;
				font-size: 32rpx;
				color: #FFFFFF;
				margin: 0 12rpx;
			}

			.dq-icon {
				width: 28rpx;
				height: 34rpx;
			}
		}

		.page_title {
			width: 100vw;
			text-align: center;
			font-weight: bold;

			image {
				width: 190rpx;
				height: 56rpx;
				margin: 0 auto;
			}
		}
	}

	.zhanwei {
		width: 100%;
		// background-color: #000;
	}

	.main-div {
		position: relative;
		width: 100%;
		min-height: 1000rpx;

		.main-bg {
			width: 100%;
			height: 1000rpx;
			position: absolute;
			top: 0;
			z-index: 0;
		}

		.m-d {
			position: relative;
			padding-top: 88rpx;
			z-index: 2;

			/deep/ uni-swiper {
				background-color: rgba(0, 0, 0, 0) !important;
			}

			/deep/ .u-indicator-item-round-active {
				width: 14rpx;
			}
		}
	}

	.gn-div {
		width: 686rpx;
		// height: 562rpx;
		padding: 42rpx 0;
		background: #FFFFFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		border: 1rpx solid #F8ECEC;
		margin: 16rpx auto;
		margin-top: 48rpx;

		.gn-item1 {
			padding: 0 42rpx;

			.item1-item {

				.item1-icon {
					width: 96rpx;
					height: 96rpx;
					margin: 0 auto;
				}

				.item-title {
					font-weight: bold;
					font-size: 28rpx;
					color: #333333;
					margin-top: 16rpx;
				}

				.item-jj {
					font-size: 24rpx;
					color: #999999;
					margin-top: 4rpx;
				}
			}
		}


	}

	.laba-div {
		padding: 0 24rpx;
		width: 686rpx;
		height: 80rpx;
		background: #FFFFFF;
		border-radius: 40rpx 40rpx 40rpx 40rpx;
		border: 2rpx solid #F8ECEC;
		margin: 0 auto;

		.laba-icon {
			width: 40rpx;
			height: 40rpx;
		}

		.laba-text {
			font-size: 24rpx;
			color: #333333;
			margin-left: 12rpx;
			width: 436rpx;
		}

		.laba-btn {
			font-size: 24rpx;
			color: #666666;
		}
	}

	.ai-div {
		width: 686rpx;
		height: 320rpx;
		margin: 20rpx auto;

		.ai-bg {
			width: 686rpx;
			height: 320rpx;
		}
	}
</style>